package com.example.modulethree.delegate

import android.app.LocalActivityManager
import android.content.Intent
import android.widget.TabHost
import com.example.modulethree.R
import com.example.mvp.delegate.BaseAppDelegate
import com.example.modulethree.activity.KotlinMVPTestActivity
import com.example.modulethree.activity.KotlinMVPTestFragmentActivity
import com.example.modulethree.activity.KotlinTestActivity


/**
 * Created by sun.li on 2018/7/3.
 * @author sun.li
 */
class KotlinTabHostTestActivityDelegate : BaseAppDelegate(){

    override fun initWidget() {
//        initTabHost()
    }

    override fun initLayoutRes(): Int {
        return R.layout.activity_kotlin_tabhost_test
    }

    fun initTabHost(manager: LocalActivityManager){
        var tabHost : TabHost = getView(R.id.th_aktt_tabhost)
        tabHost.setup(manager)
        var intent1 = Intent(context,KotlinMVPTestActivity::class.java)
        val page1 = tabHost.newTabSpec("tab1")
                .setIndicator("叫兽").setContent(intent1)
        tabHost.addTab(page1)
        var intent2 = Intent(context,KotlinMVPTestFragmentActivity::class.java)
        val page2 = tabHost.newTabSpec("tab2")
                .setIndicator("老湿").setContent(intent2)
        tabHost.addTab(page2)
        var intent3 = Intent(context,KotlinTestActivity::class.java)
        val page3 = tabHost.newTabSpec("tab3")
                .setIndicator("哪吒").setContent(intent3)
        tabHost.addTab(page3)
    }

    fun clearTabHost(){
        var tabHost : TabHost? = getView(R.id.th_aktt_tabhost)
        tabHost?.currentTab = 0
        tabHost?.clearAllTabs()
    }
}